<template>
  <div>
    <div class="box" v-bind="{style:'height:'+ulWidth+'px'}">
      <ul v-bind="{style:'height:'+ulWidth+'px'}">
        <li v-for="item in list" @click="getMusic(item.id)" :class="{'pigment':id == item.id}">{{ item.name }}</li>
      </ul>
    </div>
    <go :id=id @send="getData" @sind="getId" v-show="datas"></go>
    <div class="sk-circle" ref="loading">
      <div class="sk-circle1 sk-child"></div>
      <div class="sk-circle2 sk-child"></div>
      <div class="sk-circle3 sk-child"></div>
      <div class="sk-circle4 sk-child"></div>
      <div class="sk-circle5 sk-child"></div>
      <div class="sk-circle6 sk-child"></div>
      <div class="sk-circle7 sk-child"></div>
      <div class="sk-circle8 sk-child"></div>
      <div class="sk-circle9 sk-child"></div>
      <div class="sk-circle10 sk-child"></div>
      <div class="sk-circle11 sk-child"></div>
      <div class="sk-circle12 sk-child"></div>
    </div>
  </div>
</template>

<script>
  //引入子组件
  import go from './Go.vue';
  export default {
    components: {
      go,
    },
    data(){
      return {
        list: [
          {name: '热门', id: 26},
          {name: '欧美', id: 3},
          {name: '流行', id: 4},
          {name: '内地', id: 5},
          {name: '港台', id: 6},
          {name: '韩国', id: 16},
          {name: '日本', id: 17},
          {name: '新歌', id: 27},
          {name: '网络歌曲', id: 28},
          {name: '音乐人', id: 32},
          {name: 'K歌金曲', id: 36}
        ],
        ulWidth: '',
        id: 26,
        datas: false,
        isShow: true,
        fatherId:202345103
      }
    },
    created(){
      this.ulWidth = (document.body.clientHeight) - 90 - 32;
    },
    methods: {
      getMusic(ids){
        this.datas = false;
        this.isShow = false;
        this.$refs.loading.style = "display:block";
        ids = ids || 26;
        this.id = ids;
      },

      getData(input){
        this.datas = input;
        this.isShow = true;
      },
      //      子组件传输过的歌曲id
      getId(input){
        this.fatherId = input
      }
    },
    watch: {
      datas: function () {
        if (this.datas !== false) {
          this.$refs.loading.style = "display:none";
        }
      },
//      监听子组件传过来的id，如果有变化则发送给App组件
      fatherId:function(){
        this.$emit('sinds',this.fatherId)
      }
    }
  }
</script>-

<style scoped>
  .box {
    height: 100%;
    width: 77px;
    float: left;
    padding-bottom: 50px;
    overflow: hidden;
  }

  ul {
    height: 500px;
    overflow-y: auto;
    background-color: #f7f7f7;
    text-align: center;
    padding-left: 0;
    margin-top: 0;
  }

  li {
    list-style: none;
    cursor: pointer;
    line-height: 50px;
  }

  .pigment {
    background-color: #EFEFF4;
  }

  /*loading动画*/
  .sk-circle {
    width: 40px;
    height: 40px;
    position: fixed;
    left: 50%;
    top: 10%;
  }

  .sk-circle .sk-child {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
  }

  .sk-circle .sk-child:before {
    content: '';
    display: block;
    margin: 0 auto;
    width: 15%;
    height: 15%;
    background-color: #333;
    border-radius: 100%;
    -webkit-animation: sk-circleBounceDelay 1.2s infinite ease-in-out both;
    animation: sk-circleBounceDelay 1.2s infinite ease-in-out both;
  }

  .sk-circle .sk-circle2 {
    -webkit-transform: rotate(30deg);
    -ms-transform: rotate(30deg);
    transform: rotate(30deg);
  }

  .sk-circle .sk-circle3 {
    -webkit-transform: rotate(60deg);
    -ms-transform: rotate(60deg);
    transform: rotate(60deg);
  }

  .sk-circle .sk-circle4 {
    -webkit-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    transform: rotate(90deg);
  }

  .sk-circle .sk-circle5 {
    -webkit-transform: rotate(120deg);
    -ms-transform: rotate(120deg);
    transform: rotate(120deg);
  }

  .sk-circle .sk-circle6 {
    -webkit-transform: rotate(150deg);
    -ms-transform: rotate(150deg);
    transform: rotate(150deg);
  }

  .sk-circle .sk-circle7 {
    -webkit-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    transform: rotate(180deg);
  }

  .sk-circle .sk-circle8 {
    -webkit-transform: rotate(210deg);
    -ms-transform: rotate(210deg);
    transform: rotate(210deg);
  }

  .sk-circle .sk-circle9 {
    -webkit-transform: rotate(240deg);
    -ms-transform: rotate(240deg);
    transform: rotate(240deg);
  }

  .sk-circle .sk-circle10 {
    -webkit-transform: rotate(270deg);
    -ms-transform: rotate(270deg);
    transform: rotate(270deg);
  }

  .sk-circle .sk-circle11 {
    -webkit-transform: rotate(300deg);
    -ms-transform: rotate(300deg);
    transform: rotate(300deg);
  }

  .sk-circle .sk-circle12 {
    -webkit-transform: rotate(330deg);
    -ms-transform: rotate(330deg);
    transform: rotate(330deg);
  }

  .sk-circle .sk-circle2:before {
    -webkit-animation-delay: -1.1s;
    animation-delay: -1.1s;
  }

  .sk-circle .sk-circle3:before {
    -webkit-animation-delay: -1s;
    animation-delay: -1s;
  }

  .sk-circle .sk-circle4:before {
    -webkit-animation-delay: -0.9s;
    animation-delay: -0.9s;
  }

  .sk-circle .sk-circle5:before {
    -webkit-animation-delay: -0.8s;
    animation-delay: -0.8s;
  }

  .sk-circle .sk-circle6:before {
    -webkit-animation-delay: -0.7s;
    animation-delay: -0.7s;
  }

  .sk-circle .sk-circle7:before {
    -webkit-animation-delay: -0.6s;
    animation-delay: -0.6s;
  }

  .sk-circle .sk-circle8:before {
    -webkit-animation-delay: -0.5s;
    animation-delay: -0.5s;
  }

  .sk-circle .sk-circle9:before {
    -webkit-animation-delay: -0.4s;
    animation-delay: -0.4s;
  }

  .sk-circle .sk-circle10:before {
    -webkit-animation-delay: -0.3s;
    animation-delay: -0.3s;
  }

  .sk-circle .sk-circle11:before {
    -webkit-animation-delay: -0.2s;
    animation-delay: -0.2s;
  }

  .sk-circle .sk-circle12:before {
    -webkit-animation-delay: -0.1s;
    animation-delay: -0.1s;
  }

  @-webkit-keyframes sk-circleBounceDelay {
    0%, 80%, 100% {
      -webkit-transform: scale(0);
      transform: scale(0);
    }
    40% {
      -webkit-transform: scale(1);
      transform: scale(1);
    }
  }

  @keyframes sk-circleBounceDelay {
    0%, 80%, 100% {
      -webkit-transform: scale(0);
      transform: scale(0);
    }
    40% {
      -webkit-transform: scale(1);
      transform: scale(1);
    }
  }

</style>
